version: '3.8'
services:
  service:
    build: 
      context: .
      args:
        NODE_ENV: 'production'
    container_name: service
    hostname: service
    ports:
      - 3000:3000
    networks:
      - app-network
    volumes:
      - ./src/:/app/src/
      - .env/:/app/.env
    restart: unless-stopped

  mongo:
    image: mongo:7.0.9
    restart: always
    ports:
      - ${DATABASE_PORT}:27017
    volumes:
      - mongo-db:/data/db
    networks:
      - app-network
    environment:
      MONGO_INITDB_ROOT_USERNAME: ${DATABASE_USER}
      MONGO_INITDB_ROOT_PASSWORD: ${DATABASE_PASSWORD}

  mongo-express:
    image: mongo-express
    restart: always
    ports:
      - 8081:8081
    networks:
      - app-network
    environment:
      ME_CONFIG_BASICAUTH_USERNAME: ${DATABASE_USER}
      ME_CONFIG_BASICAUTH_PASSWORD: ${DATABASE_PASSWORD}
      ME_CONFIG_MONGODB_URL: mongodb://${DATABASE_USER}:${DATABASE_PASSWORD}@mongo:${DATABASE_PORT}/

  maildev:
    build:
      context: .
      dockerfile: maildev.Dockerfile
    ports:
      - ${MAIL_CLIENT_PORT}:1080
      - ${MAIL_PORT}:1025
    networks:
      - app-network

networks:
  app-network:
    name: app-network
    driver: bridge

volumes:
  mongo-db: